package com.wholesale.beans;

import org.json.JSONException;
import org.json.JSONObject;


public class GoodsInfo {
	private int goodsId ;
	private int catId ;
	private String goodsSn ;
	private String goodsName ;
	private String goodsNameStyle ;
	private double shopPrice ;
	private double promotePrice ;
	private String goodsBrief ;
	private String goodsThumb ;
	private boolean isBest ;
	private boolean isNew ;
	private boolean isHot ;
	private boolean isPromote ;
	private JSONObject jsonObject;
	public int getGoodsId() {
		return goodsId;
	}
	public void setGoodsId(int goodsId) {
		this.goodsId = goodsId;
	}
	public int getCatId() {
		return catId;
	}
	public void setCatId(int catId) {
		this.catId = catId;
	}
	public String getGoodsSn() {
		return goodsSn;
	}
	public void setGoodsSn(String goodsSn) {
		this.goodsSn = goodsSn;
	}
	public String getGoodsName() {
		return goodsName;
	}
	public void setGoodsName(String goodsName) {
		this.goodsName = goodsName;
	}
	public String getGoodsNameStyle() {
		return goodsNameStyle;
	}
	public void setGoodsNameStyle(String goodsNameStyle) {
		this.goodsNameStyle = goodsNameStyle;
	}
	public double getShopPrice() {
		return shopPrice;
	}
	public void setShopPrice(double shopPrice) {
		this.shopPrice = shopPrice;
	}
	public double getPromotePrice() {
		return promotePrice;
	}
	public void setPromotePrice(double promotePrice) {
		this.promotePrice = promotePrice;
	}
	public String getGoodsBrief() {
		return goodsBrief;
	}
	public void setGoodsBrief(String goodsBrief) {
		this.goodsBrief = goodsBrief;
	}
	public String getGoodsThumb() {
		return goodsThumb;
	}
	public void setGoodsThumb(String goodsThumb) {
		this.goodsThumb = goodsThumb;
	}
	public boolean isBest() {
		return isBest;
	}
	public void setBest(boolean isBest) {
		this.isBest = isBest;
	}
	public boolean isNew() {
		return isNew;
	}
	public void setNew(boolean isNew) {
		this.isNew = isNew;
	}
	public boolean isHot() {
		return isHot;
	}
	public void setHot(boolean isHot) {
		this.isHot = isHot;
	}
	public boolean isPromote() {
		
		return isPromote;
	}
	public void setPromote(boolean isPromote) {
		this.isPromote = isPromote;
	}
	
	public String toJsonString(){
		JSONObject loginObject = new JSONObject();
		try {
			loginObject.put("goodsId", goodsId);
			loginObject.put("catId", catId);
			loginObject.put("goodsSn", goodsSn);
			loginObject.put("goodsName", goodsName);
			loginObject.put("goodsNameStyle", goodsNameStyle);
			loginObject.put("shopPrice", shopPrice);
			loginObject.put("promotePrice", promotePrice);
			loginObject.put("goodsBrief", goodsBrief);
			loginObject.put("goodsThumb", goodsThumb);
			if(isBest){
				loginObject.put("isBest", 1);	
			}else{
				loginObject.put("isBest", 0);
			}
			if(isNew){
				loginObject.put("isNew", 1);	
			}else{
				loginObject.put("isNew", 0);
			}
			if(isHot){
				loginObject.put("isHot", 1);	
			}else{
				loginObject.put("isHot", 0);
			}
			if(isPromote){
				loginObject.put("isPromote", 1);	
			}else{
				loginObject.put("isPromote", 0);
			}
		} catch (Exception e) {
		}
		return loginObject.toString();
	}
	
	public void jsonAnalytic(String jsonString){
		
		try {
			jsonObject = new JSONObject(jsonString);
			jsonAnalytic(jsonObject);
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public void jsonAnalytic(JSONObject jsonObject){
		this.jsonObject = jsonObject;
		
			try {
				goodsId = jsonObject.getInt("goodsId");
			} catch (JSONException e) {
			}
			try {
				catId = jsonObject.getInt("catId");
			} catch (JSONException e) {
			}
			try {
				goodsSn = jsonObject.getString("goodsSn");
			} catch (JSONException e) {
			}
			try {
				goodsName = jsonObject.getString("goodsName");
			} catch (JSONException e) {
			}
			try {
				goodsNameStyle = jsonObject.getString("goodsNameStyle");
			} catch (JSONException e) {
			}
			try {
				shopPrice = jsonObject.getDouble("shopPrice");
			} catch (JSONException e) {
			}
			try {
				promotePrice = jsonObject.getDouble("promotePrice");
			} catch (JSONException e) {
			}
			try {
				goodsBrief = jsonObject.getString("goodsBrief");
			} catch (JSONException e) {
			}
			try {
				goodsThumb = jsonObject.getString("goodsThumb");
			} catch (JSONException e) {
			}
			try {
				if(!jsonObject.getString("isBest").equals("") && jsonObject.getString("isBest").equals("1")){
					isBest = true ;
				}
			} catch (JSONException e) {
			}
			try {
				if(!jsonObject.getString("isNew").equals("") && jsonObject.getString("isNew").equals("1")){
					isNew = true ;
				}
			} catch (JSONException e) {
			}
			try {
				if(!jsonObject.getString("isHot").equals("") && jsonObject.getString("isHot").equals("1")){
					isHot = true ;
				}
			} catch (JSONException e) {
			}
			try {
				if(!jsonObject.getString("isPromote").equals("") && jsonObject.getString("isPromote").equals("1")){
					isPromote = true ;
				}
			} catch (JSONException e) {
			}
		
	}
}
